﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using ZLDC.Common.Estate;
namespace ZLDC.Estate.UM
{
    public partial class WordReplaceList : _PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
            if (!IsPostBack)
            {
                if (!ZLDC.Common.BaseUser.UserInfo.GetPopedom("保存经理级意见"))
                {
                    btnSave.Visible = false;
                }

                NewMethod();
            }
            
        }

        private void NewMethod()
        {
            int id = Convert.ToInt32(Request.QueryString["id"]);
            DataSet ds = new DataSet();
            ds = ZLDC.Topo.BLL.Estate.DayReportBLL.SelectDayReportListById(id);
            if (ds.Tables[0].Rows.Count > 0)
            {
                lblDept.Text = ds.Tables[0].Rows[0]["adddept"].ToString();//部门
                lblDate.Text = ds.Tables[0].Rows[0]["adddate"].ToString();//时间
                lblUser.Text = ds.Tables[0].Rows[0]["adduser"].ToString();//人员
                lblTitle.Text = ds.Tables[0].Rows[0]["title"].ToString();//标题
                txtContent.Value = ds.Tables[0].Rows[0]["content"].ToString();//内容
                txtAdvise.Value = ds.Tables[0].Rows[0]["adviseandplan"].ToString();//
            }
            ds.Tables[0].Clear();
            DataSet ds1 = ZLDC.Topo.BLL.Estate.DayReportReplBLL.SelectDayReportReplyListById(id);
            if (ds1.Tables[0].Rows.Count > 0)
            {
                txtManageAgree.Value = ds1.Tables[0].Rows[0]["replycontent"].ToString();//点评信息
                replyId.Value = ds1.Tables[0].Rows[0]["id"].ToString();
            }
            ds1.Tables[0].Clear();
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(replyId.Value);
            
            int reportId = Convert.ToInt32(Request.QueryString["id"]);
            string replycontent = txtManageAgree.Value.Trim();

            string outmsg=ZLDC.Topo.BLL.Estate.DayReportReplBLL.p_dayReport_Reply_save(id, reportId, replycontent);

            if (outmsg == "添加成功"  || outmsg=="更新成功")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>window.location.reload( ); window.close();</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('" + outmsg + "')</script>");
            }
        }

       
    }
}
